<?php
$_GET = array_merge($_GET,$_POST);
include 'config.php';
include ROOT_DIR.'/search.class.php';

if(isset($_GET['keyword']) && $_GET['keyword']!='')
{
	$page = max(1,intval($_GET['page']));
	$keyword = str_replace('-',' ',$_GET['keyword']);
	$title = search::convertUnicode($keyword);//.' - Even Tim Kiem';	
	list($arrData,$total) = search::getContentToAPIGoogle($keyword,$page);
	$strHTML='';
	//print_r($arrData); exit;
	foreach($arrData as $k=>$itemWeb)
	{
		$strHTML.="<div class=\"main_result\"><p><a target=\"_blank\" href=\"$itemWeb->unescapedUrl\" rel=\"nofollow\">$itemWeb->title</a></p><p>$itemWeb->content</p><p><span>$itemWeb->visibleUrl</span></p></div>";
	}
	$strUrlPage = SEARCH_EVEN.'/%s%/'.$_GET['keyword'].'.html';
	$strEvent 	= '';			
	$title = $keyword.' | '.$title.' - Even Tim Kiem123';
	list($strPage,$strResult) = search::getPagesLinks($total,$page,8,$strUrlPage,$strEvent);	
	ob_start();
	include(ROOT_DIR.'/result.html');
	$search = ob_get_contents();
	ob_end_clean();	
}
else
{
	ob_start();
	include(ROOT_DIR.'/search.html');
	$search = ob_get_contents();
	ob_end_clean();	
}
$WEBSTATIC =WEBSTATIC;
$SEARCH_EVEN = SEARCH_EVEN;
eval("\$str = \"$search\";");
echo $str;
?>
